<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      table {
        width: 800px;
        height: 250px;
        border: 1px solid #000;
        margin: 100px auto;
      }

      td {
        height: 40px;
        border: 1px solid #000;
        text-align: center;
      }
    </style>
  </head>
  <body>
    <table id="app">
      <thead>
        <caption>
          <h2>欢迎光临—vue开发的收银系统_水果店</h2>
        </caption>
      </thead>
      <tbody>
        <tr>
          <td>苹果10¥/斤,折扣8折</td>
        </tr>
        <tr>
          <td>请输入你要购买的斤数<input v-model="num" type="number" /></td>
        </tr>
        <tr>
          <td><button @click="fn">结账买单~</button></td>
        </tr>
        <tr>
          <td>结账单:总价{{total}}¥元 折后:{{price}}¥元 省了:{{save}}¥元</td>
        </tr>
      </tbody>
    </table>
    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          num: "",
          total: "",
          price: "",
          save: "",
        },
        methods: {
          fn() {
            this.total = this.num * 10
            this.price = this.total * 0.8
            this.save = this.total - this.price
          },
        },
      })
    </script>
  </body>
</html>
